<?php

namespace App\Http\Requests\Api;

class AddressRequest extends FormRequest
{
    public function rules()
    {
        switch ($this->method()) {
            case 'POST':
                $arr = [
                    'contact_address' => 'required|string',
                    'contact_name' => 'required|string|max:20',
                    'contact_phone' => 'required|phone:CN,mobile',
                ];
                return $arr;
                break;
        }
    }

    public function attributes()
    {
        return [
            'contact_address' => '具体地址',
            'contact_name' => '收货人',
            'contact_phone' => '手机号',
        ];
    }

    public function messages()
    {
        return [
            'contact_phone.phone' => '手机号不存在',
        ];
    }
}
